home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
program
/
jdp1_4.zip
/
JDP1_4.EXE
/
data.1
/
JDPLayout1.java
< prev
next >
Wrap
Text File
|
1996-11-06
|
13KB
|
473 lines
>XXX0455 Total lines for the build status message calculation
//--------------------------------------------------------------------
//
>001// Module: <JDPModule>
>002// Description: <Class Description>
//
//--------------------------------------------------------------------
import java.awt.*;
import java.applet.*;
import java.util.StringTokenizer;
import java.util.Vector;
>003public class <JDPUserBill> extends JDPClassLayout {
JDPUser user;
JDPJagg jaggSQL;
JDPWhereClause jdpWhereClause;
JDPSearchResults searchResults;
JDPPopupMessage popuppanel;
JDPTabSelectPanel tabPanel;
String[] psortChoice;
String[] pdisplayChoice;
int itemIndex;
boolean insertRequested = false;
boolean deleteRequested = false;
String pfromWhereClause;
Vector pmatchUsing;
Vector pactualmatchUsing;
//
// Declare screen components
//
>004 <TextField username>;
public void InitClass(JDPUser user, Panel targetPanel, String moduleParameter) {
this.user = user;
//
// Set JAGG settings for this class
//
jaggSQL = new JDPJagg(user.jaggPath);
jaggSQL.setNULL("space");
>997 jaggSQL.setMRW("<maxRows>");
>998 jaggSQL.setDSN("<datasource>");
>999 jaggSQL.setCSTR("<connectstr>");
setLayout(new BorderLayout());
setFont(user.plainFont);
popuppanel = new JDPPopupMessage(user,targetPanel);
targetPanel.add(popuppanel);
Panel mainPanel = new Panel();
mainPanel.setLayout(new BorderLayout());
Panel centerPanel = new Panel();
centerPanel.setLayout(new BorderLayout());
Panel centerMainPanel = new Panel();
centerMainPanel.setLayout(new BorderLayout());
Panel leftPanel = new Panel();
leftPanel.setLayout(new BorderLayout());
//
// Define parameters for JDPSearchResults
//
>005 String pselectFields = "<>"; String[] psdisplayFields = {<>};
>006 pfromWhereClause = "<FROM JDPUser WHERE >";
>007 psortChoice = new String[<5>];
>008 psortChoice[<0>] = "<username>";
>009 String[] psortChoiceText = {<"Sort by User Name","Sort by Card Number">};
pdisplayChoice = psortChoice;
>010 boolean pdisplayCount = <true>;
>011 String pcountText = "<Total Entries:>";
//
// Create an instance of screen components
//
>012 <username> = new <TextField("",20)>;
//
// Initialise any choice components
//
loadChoices();
//
// Add components to the screen
//
>058 JDPScrollPanel[] centerTopPanel = new JDPScrollPanel[<>];
>059 centerTopPanel[<>] = new JDPScrollPanel();
>013 centerTopPanel[<>].add("Left",new JDPWrapLabel(user,"<User Name:>",Color.<labelColor>));
>014 centerTopPanel[<>].add("Right",centerR<0>);
if (centerTopPanel.length == 1) {
centerMainPanel.add("Center",centerTopPanel[0]);
} else {
>060 String[] titles = {<>};
tabPanel = new JDPTabSelectPanel(user,titles,centerTopPanel,"North");
centerMainPanel.add("Center",tabPanel);
}
//
// Set screen component attributes
//
>039 <username>.setForeground(Color.<fcolor>);
>040 <username>.setBackground(Color.<bcolor>);
>048 popuppanel.addComponent(<>,"<>","<>");
//
// Add buttons to the bottom of the panel
//
if (moduleParameter.compareTo("Inquiry") == 0) {
>041 <username>.setEditable(false);
} else {
>042 <username>.setEditable(<editable>);
>015 String buttons[] = {<" Apply ","Reset","New","Copy","Remove">};
>047 int icons[] = {<>};
JDPButtons btns = new JDPButtons(user, buttons, icons, JDPButtons.HORIZONTAL);
centerMainPanel.add("South",btns);
>046 popuppanel.addComponent(btns.button[<0>],"<>","<>");
}
mainPanel.add("Center",centerMainPanel);
//
// Define parameters for JDPWhereClause
//
>016 String[] pchooseFrom = new String[<7>];
>017 pchooseFrom[<0>] = "<Account Name>";
>018 String[] pactualchooseFrom = new String[<7>];
>019 pactualchooseFrom[<0>] = "<username>";
>024 boolean[] constantIsString = new boolean[<7>];
>025 constantIsString[<0>] = <true>;
>026 int[] constantLength = new int[<7>];
>027 constantLength[<0>] = <20>;
//
// Add JDPWhereClause search panel
//
if (pchooseFrom.length > 0) {
>028 jdpWhereClause = new JDPWhereClause(user, targetPanel, "<UserBill>", true, "<pinitChoice>", pchooseFrom, pactualchooseFrom,
pmatchUsing, pactualmatchUsing, null, null,
constantLength, constantIsString);
leftPanel.add("North",jdpWhereClause);
}
//
// Add JDPSearchResults result list
//
if (psortChoice.length > 0) {
>029 searchResults = new JDPSearchResults(user, targetPanel, <false>, jaggSQL, <false>, pselectFields, psdisplayFields, pfromWhereClause, psortChoiceText, psortChoice, pdisplayChoice, "<pinitChoice>", pdisplayCount, pcountText);
>055 int icons[] = {<>};
>056 searchResults.setMinWidth(<>);
searchResults.setIcons(icons);
leftPanel.add("Center",searchResults);
mainPanel.add("West",leftPanel);
}
>030 add("Center",new JDPChiselFramePanel(user,"<User Billing Details>",mainPanel,"North"));
if (psortChoice.length > 0) {
newSearch();
}
//
// Add the handle to this panel to the global vector so other panels can
// access this one
//
user.gParm.addElement(this);
clearFields();
}
//
// Handle screen events
//
public boolean handleEvent(Event e) {
switch (e.id) {
case Event.ACTION_EVENT:
if (e.target instanceof List) {
if (e.target.equals(searchResults.resultList)) {
loadData();
return true;
}
}
if (e.target instanceof JDPTreePicker) {
if (e.target.equals(searchResults.tree)) {
loadData();
return true;
}
}
if (e.target instanceof Button) {
String choice = (String)e.arg;
if (choice.trim().compareTo("Apply") == 0) {
if (checkFields()) {
if (insertRequested) {
saveData();
newSearch();
} else {
saveData();
}
}
return true;
}
if (choice.trim().compareTo("Reset") == 0) {
loadData();
return true;
}
if (choice.trim().compareTo("New") == 0) {
insertRequested = true;
clearFields();
return true;
}
if (choice.trim().compareTo("Submit") == 0) {
insertRequested = true;
if (checkFields()) {
saveData();
}
return true;
}
if (choice.trim().compareTo("Copy") == 0) {
insertRequested = true;
return true;
}
if (choice.trim().compareTo("Remove") == 0) {
>054 String removeMsg = "<>";
if (removeMsg.equals("") || user.mainmsg.getStatusMsg().equals(removeMsg)) {
insertRequested = false;
deleteRequested = true;
saveData();
newSearch();
} else {
user.mainmsg.setStatusMsg(removeMsg,15);
}
return true;
}
if (choice.trim().compareTo("Search") == 0) {
insertRequested = false;
deleteRequested = false;
newSearch();
return true;
}
return true;
}
if (e.target instanceof Choice) {
return true;
}
if (e.target instanceof TextField) {
if ((jdpWhereClause != null) && (e.target.equals(jdpWhereClause.matchConstant))) {
insertRequested = false;
deleteRequested = false;
newSearch();
return true;
}
checkFields();
return true;
}
return false;
case Event.KEY_PRESS:
if (e.key == '\t') {
// handle tabbing between components
if (e.modifiers != Event.SHIFT_MASK) {
>031 if (e.target.equals(<username>)) { user.u.cursor(<username>); return true; }
} else {
>038 if (e.target.equals(<username>)) { user.u.cursor(<username>); return true; }
}
return true;
}
return false;
case Event.WINDOW_EXPOSE:
if (e.target instanceof JDPTabSelectPanel) {
if (e.target.equals(user.jdpMenuPanel)) {
//
// This is where you place code to get executed when this panel is
// reactivated from the tab menu
//
return true;
}
}
return false;
case Event.MOUSE_MOVE:
case Event.MOUSE_ENTER:
case Event.MOUSE_EXIT:
popuppanel.postEvent(e);
return false;
default:
return false;
}
}
//
// Retrieve the handle to another panel so as to be able to interact with it
//
public void retrieveHandle() {
for (int ix=0; ix<user.gParm.size(); ix++) {
//
// Activate the next four lines of code to retrieve the handle to another
// Panel within your JDP system. Of course you should declare the variable
// at the top of this source instead of within this method so you can
// access it from all the methods within this class. You only need to
// substitute DemoClass with the name ouf your class. You should call this
// method from somewhere else in this class. To access a variable from
// your resulting class use:
// if (DemoClassHandle != null) mynewvar = demoClassHandle.variable;
//
// if (user.gParm.elementAt(ix) instanceof DemoClass19) {
// DemoClass19 DemoClassHandle = (DemoClass19)user.gParm.elementAt(ix);
// return;
// }
}
}
//
// The search button was pressed so rerun the query with the new search criteria
//
public void newSearch() {
String whereClause;
whereClause = pfromWhereClause;
if (jdpWhereClause != null) {
whereClause = whereClause + " AND " + jdpWhereClause.whereClause;
}
searchResults.setFromWhereClause(whereClause);
>057 searchResults.clearList(<>);
searchResults.loadList();
}
//
// Load the selected item
//
public void loadData() {
StringTokenizer stok;
int recCount = 0;
Vector results = new Vector();
String sep = jaggSQL.getSEP();
int actualRows = 0;
String row;
String tempText;
if ((itemIndex = searchResults.getSelectedIndex()) < 0) {
clearFields();
return;
}
>032 String SQL = <SELECT username,firstname,lastname,status,cardnum,cardexpiry,cardname FROM JDPUser (NOLOCK) WHERE userid = " + thisuserid>;
user.mainmsg.setStatusMsg("Accessing database...", 0);
recCount = jaggSQL.execSQL(SQL, results);
if(recCount == -1) {
user.u.setSqlMessage(jaggSQL,SQL);
return;
}
if(recCount >= 1) {
row = (String)results.elementAt(0);
if ((row != null) && (row.trim().compareTo("") != 0)) {
stok = new StringTokenizer(row);
>033 <username>.setText(stok.nextToken(sep).trim());
}
if(recCount > 1) {
user.mainmsg.setStatusMsg("Multiple records found - first match only displayed.", 10);
} else {
user.mainmsg.clearStatusMsg();
}
} else {
user.mainmsg.setStatusMsg("Requested entry does not exist.", 10);
clearFields();
}
}
//
// Save the selected item
//
public boolean saveData() {
int recCount = 0;
Vector results = new Vector();
String sep = jaggSQL.getSEP();
String SQL = "";
if (insertRequested) {
>034 SQL = <INSERT INTO >;
} else {
itemIndex = searchResults.getSelectedIndex();
if (itemIndex < 0) {
user.mainmsg.setStatusMsg("You must first make a selection",5);
return false;
}
if (deleteRequested) {
>035 SQL = <DELETE FROM >;
} else {
>036 SQL = <UPDATE >;
}
}
user.mainmsg.setStatusMsg("Accessing database...", 0);
recCount = jaggSQL.execSQL(SQL, results);
if(recCount == -1) {
user.u.setSqlMessage(jaggSQL,SQL);
return false;
}
if(recCount == 1) {
if (insertRequested) {
user.mainmsg.setStatusMsg("Record successfully added.",3);
} else
if (deleteRequested) {
user.mainmsg.setStatusMsg("Record successfully removed.",3);
} else {
user.mainmsg.setStatusMsg("Record successfully updated.",3);
}
} else {
user.u.setSqlMessage(jaggSQL,SQL);
}
insertRequested = false;
deleteRequested = false;
return true;
}
//
// Clear the screen fields for a new option
//
public void clearFields() {
>037 <username>.setText("<>");
}
//
// Load all of the Screen Choices
//
public void loadChoices() {
pmatchUsing = new Vector();
pactualmatchUsing = new Vector();
>020 pmatchUsing.addElement(new Vector());
>022 pactualmatchUsing.addElement(new Vector());
>021 ((Vector)pmatchUsing.elementAt(<0>)).addElement("<Begins with>");
>023 ((Vector)pactualmatchUsing.elementAt(<0>)).addElement("< like >");
>043
>044 new JDPLoadChoice(user,jaggSQL,<choicename>,"<choicecolumnname>","<actualcolumnname>","<tablename>","<whereclause>",value<columnname>);
}
//
// Perform component validations
//
public boolean checkFields() {
>045 if (!user.u.<isnumeric>(<field>,user.mainmsg,"<>")) return false;
return true;
}
}